package com.linwen.javase.desgin_pattern.action.vistior;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @ClassName ObjectStructure
 * @Description
 * @Author lin
 * @Date 2022/6/30 上午12:51
 * @Version V1.0
 */
//对象结构角色
class ObjectStructure {
    private List<Element> list = new ArrayList<Element>();
    public void accept(Visitor visitor) {
        Iterator<Element> i = list.iterator();
        while (i.hasNext()) {
            ((Element) i.next()).accept(visitor);
        }
    }
    public void add(Element element) {
        list.add(element);
    }
    public void remove(Element element) {
        list.remove(element);
    }
}